<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <h1>axios请求别名</h1>
    <button id="btnget">发送查询get按钮</button>
    <button id="btnpost">发送新增post按钮</button>
    <button id="btnupdate">发送新增update按钮</button>
    <button id="btndelete">发送删除delete按钮</button>
    <script>
        const oBtnGet=document.getElementById('btnget')
        const oBtnPost=document.getElementById('btnpost')
        const oBtnUpdate=document.getElementById('btnupdate')
        const oBtnDelete=document.getElementById('btndelete')
        oBtnGet.onclick= async function (){
            const re =await axios.get('/user',{
                params:{
                    userId:'001'
                }
            })
            console.log(re.data);
        }
        oBtnPost.onclick=async function (){
            const re=await axios.post('/adduser',{
                name:'lao',
                age:19,
                sex:'男'
            })
            console.log((re.data));
        }
        oBtnUpdate.onclick=async function (){
            const re =await axios.put('/updateuser',{
                userId:'001',
                age:18,
                sex:'女'
            })
            console.log(re.data);
        }
        oBtnDelete.onclick=async function (){
            const re=await axios.delete('/deleteuser',{
                params:{
                    userId:'001'
                }
            })
            console.log(re.data);
        }
   </script>
</body>
</html>